#!/data/Software/mydan/perl/bin/perl -I/data/Software/mydan/JOB/lib -I/data/Software/mydan/JOB/private/lib
use strict;
use warnings;
use MYDB;
use FindBin qw( $RealBin );
use Data::Dumper;

use MYDan::Util::OptConf;
use Code;

=head1 SYNOPSIS

 $0 [--to user1@job.com ]

=cut

my $option = MYDan::Util::OptConf->load();
my %o = $option->get( qw( to=s ) )->dump();
$option->assert( qw( to ) );

my $ok = Code->new( 'notify.plugin/email' )->run( 
    'finishtime' => '2018-01-20 17:15:54',
    'status' => 'fail',
    'calltype' => 'page',
    'name' => 'foo',
    'id' => 57,
    'uuid' => 'ByrweYI7PQHJ',
    'user' => 'debug@job',
    'projectid' => 1,
    'starttime' => '2018-01-20 17:15:21',
    to => [ $o{to} ],
    notifytype => 'notify',
    'environment' => {
        notifyTemplateEmailTitle => 'projectid: ${projectid} job ${status}',
        notifyTemplateEmailContent => 'task ${uuid} :${status}',
        notifyTemplateSmsContent => 'projectid=${projectid} taskuuid=${uuid}: ${status}',
    }

);

$ok ? exit 0 : exit 1;
